package com.topvision.bureau;

import android.app.Application;
import android.util.Log;

import com.github.anrwatchdog.ANRError;
import com.github.anrwatchdog.ANRWatchDog;
import com.topvision.commomsdk.TvSdk;
import com.topvision.voicesdk.VoiceApplication;

import java.io.IOException;

/**
 * Created by Administrator on 2017/6/19.
 */

public class MyApplication extends VoiceApplication {
    ANRWatchDog anrWatchDog = new ANRWatchDog(2000);

    @Override
    public void onCreate() {
        super.onCreate();
        //开启错误日志收集
        TvSdk.startCrashBugCollection(getApplicationContext(), "7a04f67c10", true);

        anrWatchDog.setANRListener(new ANRWatchDog.ANRListener() {
            @Override
            public void onAppNotResponding(ANRError error) {
                Log.e("ANR-Watchdog", "Detected Application Not Responding!");
                try {
                    System.exit(0);
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
                throw error;
            }
        });
        anrWatchDog.start();
    }
}
